#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n,m,q;
    cin>>n>>m>>q;
    vector<vector<ll>> nums(n+1, vector<ll>(m+1));
    vector<vector<ll>> dp(n+1, vector<ll>(m+1));
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            cin>>nums[i][j];
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            dp[i][j]=dp[i-1][j]+dp[i][j-1]+nums[i][j]-dp[i-1][j-1];
    while(q--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        ll mysum=dp[c][d]-dp[a-1][d]-dp[c][b-1]+dp[a-1][b-1];
        cout<<mysum<<endl;
    }
   return 0;
}
